package com.junwell.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.junwell.entity.Car;
import com.junwell.entity.Station;
import com.junwell.mapper.StationMapper;
import com.junwell.service.StationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 */
@Service
public class StationServiceImpl extends ServiceImpl<StationMapper, Station> implements StationService {

    @Autowired
    private  StationMapper stationMapper;

    @Override
    public boolean add(Station station) {
        int i = stationMapper.insert(station);
        return i>0? true:false;
    }

    @Override
    public Station viewOne(Integer id) {
        QueryWrapper<Station> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        Station station = stationMapper.selectOne(queryWrapper);
        return  station;
    }

    @Override
    public boolean update(Station station) {
        int i = stationMapper.updateById(station);
        return i>0? true:false;
    }

    @Override
    public boolean delete(Integer id) {
        QueryWrapper<Station> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        int i = stationMapper.delete(queryWrapper);
        return i>0? true:false;
    }
}
